

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>federatedml.param.base_param &mdash; FATE 1.0 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script type="text/javascript" src="../../../_static/jquery.js"></script>
        <script type="text/javascript" src="../../../_static/underscore.js"></script>
        <script type="text/javascript" src="../../../_static/doctools.js"></script>
        <script type="text/javascript" src="../../../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html" class="icon icon-home"> FATE
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">FATE</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../../index.html">Module code</a> &raquo;</li>
        
      <li>federatedml.param.base_param</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for federatedml.param.base_param</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/bin/env python</span>
<span class="c1"># -*- coding: utf-8 -*-</span>

<span class="c1">#</span>
<span class="c1">#  Copyright 2019 The FATE Authors. All Rights Reserved.</span>
<span class="c1">#</span>
<span class="c1">#  Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span>
<span class="c1">#  you may not use this file except in compliance with the License.</span>
<span class="c1">#  You may obtain a copy of the License at</span>
<span class="c1">#</span>
<span class="c1">#      http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="c1">#</span>
<span class="c1">#  Unless required by applicable law or agreed to in writing, software</span>
<span class="c1">#  distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span>
<span class="c1">#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<span class="c1">#  See the License for the specific language governing permissions and</span>
<span class="c1">#  limitations under the License.</span>
<span class="c1">#</span>
<span class="kn">import</span> <span class="nn">builtins</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">federatedml.util</span> <span class="k">import</span> <span class="n">consts</span>


<div class="viewcode-block" id="BaseParam"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam">[docs]</a><span class="k">class</span> <span class="nc">BaseParam</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">pass</span>

<div class="viewcode-block" id="BaseParam.check"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check">[docs]</a>    <span class="k">def</span> <span class="nf">check</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">&quot;Parameter Object should have be check&quot;</span><span class="p">)</span></div>

<div class="viewcode-block" id="BaseParam.validate"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.validate">[docs]</a>    <span class="k">def</span> <span class="nf">validate</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">builtin_types</span> <span class="o">=</span> <span class="nb">dir</span><span class="p">(</span><span class="n">builtins</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">func</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;ge&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_greater_equal_than</span><span class="p">,</span>
                     <span class="s2">&quot;le&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_less_equal_than</span><span class="p">,</span>
                     <span class="s2">&quot;in&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_in</span><span class="p">,</span>
                     <span class="s2">&quot;not_in&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_not_in</span><span class="p">,</span>
                     <span class="s2">&quot;range&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_range</span>
                     <span class="p">}</span>
        <span class="n">home_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">realpath</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)))</span>
        <span class="n">param_validation_path_prefix</span> <span class="o">=</span> <span class="n">home_dir</span> <span class="o">+</span> <span class="s2">&quot;/param_validation/&quot;</span><span class="p">;</span>

        <span class="n">param_name</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span><span class="p">;</span>
        <span class="n">param_validation_path</span> <span class="o">=</span> <span class="s2">&quot;/&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">param_validation_path_prefix</span><span class="p">,</span> <span class="n">param_name</span> <span class="o">+</span> <span class="s2">&quot;.json&quot;</span><span class="p">])</span>

        <span class="n">validation_json</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="nb">print</span> <span class="p">(</span><span class="s2">&quot;param validation path is </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">home_dir</span><span class="p">))</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">param_validation_path</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fin</span><span class="p">:</span>
                <span class="n">validation_json</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">fin</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="k">return</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_validate_param</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">validation_json</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">_validate_param</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param_obj</span><span class="p">,</span> <span class="n">validation_json</span><span class="p">):</span>
        <span class="n">default_section</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">param_obj</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span>
        <span class="n">var_list</span> <span class="o">=</span> <span class="n">param_obj</span><span class="o">.</span><span class="vm">__dict__</span>

        <span class="k">for</span> <span class="n">variable</span> <span class="ow">in</span> <span class="n">var_list</span><span class="p">:</span>
            <span class="n">attr</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">param_obj</span><span class="p">,</span> <span class="n">variable</span><span class="p">)</span>
            
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">attr</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">builtin_types</span> <span class="ow">or</span> <span class="n">attr</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">variable</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">validation_json</span><span class="p">:</span>
                    <span class="k">continue</span>

                <span class="n">validation_dict</span> <span class="o">=</span> <span class="n">validation_json</span><span class="p">[</span><span class="n">default_section</span><span class="p">][</span><span class="n">variable</span><span class="p">]</span>
                <span class="n">value</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">param_obj</span><span class="p">,</span> <span class="n">variable</span><span class="p">)</span>
                <span class="n">value_legal</span> <span class="o">=</span> <span class="kc">False</span>

                <span class="k">for</span> <span class="n">op_type</span> <span class="ow">in</span> <span class="n">validation_dict</span><span class="p">:</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">[</span><span class="n">op_type</span><span class="p">](</span><span class="n">value</span><span class="p">,</span> <span class="n">validation_dict</span><span class="p">[</span><span class="n">op_type</span><span class="p">]):</span>
                        <span class="n">value_legal</span> <span class="o">=</span> <span class="kc">True</span>
                        <span class="k">break</span>

                <span class="k">if</span> <span class="ow">not</span> <span class="n">value_legal</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;Plase check runtime conf, </span><span class="si">{}</span><span class="s2"> = </span><span class="si">{}</span><span class="s2"> does not match user-parameter restriction&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">variable</span><span class="p">,</span> <span class="n">value</span><span class="p">))</span>

            <span class="k">elif</span> <span class="n">variable</span> <span class="ow">in</span> <span class="n">validation_json</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_validate_param</span><span class="p">(</span><span class="n">attr</span><span class="p">,</span> <span class="n">validation_json</span><span class="p">)</span>

<div class="viewcode-block" id="BaseParam.check_string"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_string">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_string</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;str&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be string type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>

<div class="viewcode-block" id="BaseParam.check_positive_integer"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_positive_integer">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_positive_integer</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be positive integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>

<div class="viewcode-block" id="BaseParam.check_positive_number"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_positive_number">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_positive_number</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be positive numeric&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>

<div class="viewcode-block" id="BaseParam.check_decimal_float"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_decimal_float">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_decimal_float</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be a float number in range [0, 1]&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>

<div class="viewcode-block" id="BaseParam.check_boolean"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_boolean">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_boolean</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>

<div class="viewcode-block" id="BaseParam.check_open_unit_interval"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_open_unit_interval">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_open_unit_interval</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&lt;=</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&gt;=</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; should be a numeric number between 0 and 1 exclusively&quot;</span><span class="p">)</span></div>

<div class="viewcode-block" id="BaseParam.check_valid_value"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_valid_value">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_valid_value</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="n">valid_values</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">param</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">valid_values</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> is not supported, it should be in </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">valid_values</span><span class="p">))</span></div>

<div class="viewcode-block" id="BaseParam.check_defined_type"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_defined_type">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_defined_type</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="n">types</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">types</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be one of </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">types</span><span class="p">))</span></div>

<div class="viewcode-block" id="BaseParam.check_and_change_lower"><a class="viewcode-back" href="../../../federatedml.param.html#federatedml.param.base_param.BaseParam.check_and_change_lower">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_and_change_lower</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">valid_list</span><span class="p">,</span> <span class="n">descr</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s1">&#39;str&#39;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be one of </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">valid_list</span><span class="p">))</span>

        <span class="n">lower_param</span> <span class="o">=</span> <span class="n">param</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">lower_param</span> <span class="ow">in</span> <span class="n">valid_list</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">lower_param</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be one of </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">valid_list</span><span class="p">))</span></div>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_greater_equal_than</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">limit</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span> <span class="o">&gt;=</span> <span class="n">limit</span> <span class="o">-</span> <span class="n">consts</span><span class="o">.</span><span class="n">FLOAT_ZERO</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_less_equal_than</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">limit</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span> <span class="o">&lt;=</span> <span class="n">limit</span> <span class="o">+</span> <span class="n">consts</span><span class="o">.</span><span class="n">FLOAT_ZERO</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_range</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">ranges</span><span class="p">):</span>
        <span class="n">in_range</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">for</span> <span class="n">left_limit</span><span class="p">,</span> <span class="n">right_limit</span> <span class="ow">in</span> <span class="n">ranges</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">left_limit</span> <span class="o">-</span> <span class="n">consts</span><span class="o">.</span><span class="n">FLOAT_ZERO</span> <span class="o">&lt;=</span> <span class="n">value</span> <span class="o">&lt;=</span> <span class="n">right_limit</span> <span class="o">+</span> <span class="n">consts</span><span class="o">.</span><span class="n">FLOAT_ZERO</span><span class="p">:</span>
                <span class="n">in_range</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="k">break</span>

        <span class="k">return</span> <span class="n">in_range</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_in</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">right_value_list</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">right_value_list</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_not_in</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">wrong_value_list</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">wrong_value_list</span></div>
</pre></div>

           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, FATE_TEAM

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>